home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 2010 April
/
PCWorld0410.iso
/
pluginy Firefox
/
3883
/
3883.xpi
/
chrome
/
tempomail.jar
/
content
/
manage.js
< prev
next >
Wrap
Text File
|
2006-12-08
|
3KB
|
87 lines
var prefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
function tempomail_getpref(pref){
var prefResult;
try{
prefResult = prefs.getCharPref(pref);
}
catch(e){
prefs.setCharPref(pref, prefDefaultVal);
prefResult = prefDefaultVal;
}
return prefResult;
}
function tempomail_options(){
tempomail_write("test");
window.openWindow(prefwindow,"chrome://tempomail/content/options.xul","","");
}
function tempomail_load(){
var prefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
var field = document.getElementById('tempomail-realname');
var prefmail = tempomail_getpref('extensions.tempomail.drn');
field.value = prefmail;
}
function tempomail_create(){
var realname = document.getElementById('tempomail-realname').value;
var duree = document.getElementById('tempomail-expire').value;
var error = document.getElementById('tempomail-error');
var bdl = document.getElementById('tempomail-bdl');
error.value = '';
if(realname.length>0 && tempomail_control(realname)){
var objHTTP;
objHTTP = new XMLHttpRequest();
objHTTP.open("POST",'http://www.tempomail.fr/creation.pl',false);
objHTTP.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
objHTTP.send('nomreel='+realname+'&duree='+duree+'&ext=yes');
var result=objHTTP.responseText;
if(result == parseInt(result)){ // si trop d'alias...
if(result == "1"){
error.value = bdl.getString('extensions.tempomail.error.2');
tempomail_write(bdl-fake.getString('extensions.tempomail.error.2'));
}
else
{
error.value = bdl.getString('extensions.tempomail.error.1');
tempomail_write(bdl-fake.getString('extensions.tempomail.error.1'));
}
}
else{
tempomail_write(result);
}
}
else
{
error.value = bdl.getString('extensions.tempomail.error.2');
tempomail_write(bdl-fake.getString('extensions.tempomail.error.2'));
}
}
function tempomail_write(mail){
var elt = window.arguments[0];
if(elt.type == 'textarea'){
if(elt.textLength == elt.selectionStart)
elt.value = elt.value + mail;
else
elt.value = elt.value.substring(0, elt.selectionStart) + mail + elt.value.substring(elt.selectionEnd, elt.textLength);
}
else{ // input
elt.value = mail;
}
}
function tempomail_control(mail){
var ch=/^[^@]+@([^@]+\.[^@]+)$/;
return (ch.test(mail) && RegExp.$1.toLowerCase()!="tempomail.fr");
}